<template>
	<view class="content">
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">日报加工</block>
		</cu-custom>
		<view class='text-content'>
			<view style="height: 10rpx;"></view>
			<view class="cu-list menu card-menu margin-bottom-xl shadow-lg radius " style="background-color: #fff;">
				<view class="u-header"><text class="tips">录入信息:</text><text class="val">{{data.testCode}}</text></view>
				<view class="u-body">
					<view class="row">
						<view class="tips">工作量</view>
						<input class="val" placeholder="请输入工作量" v-model="param.gzl" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">初诊</view>
						<input class="val" placeholder="请输入初诊" v-model="param.cz" type="digit"/>
					</view>
 					<view class="row">
						<view class="tips">指定患者</view>
						<input class="val" placeholder="请输入指定患者" v-model="param.zdhz" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">义诊</view>
						<input class="val" placeholder="请输入义诊" v-model="param.yz" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">挂号诊查费</view>
						<input class="val" placeholder="请输入挂号诊查费" v-model="param.ghzcf" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">床位费</view>
						<input class="val" placeholder="请输入床位费" v-model="param.cwf" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">功能科检查</view>
						<input class="val" placeholder="请输入功能科检查" v-model="param.gnkjc" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">化验费</view>
						<input class="val" placeholder="请输入化验费" v-model="param.hyf" type="digit"/>
					</view>					
					<view class="row">
						<view class="tips">治疗费</view>
						<input class="val" placeholder="请输入治疗费" v-model="param.zlf" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">透药费</view>
						<input class="val" placeholder="请输入透药费" v-model="param.tyf" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">合计</view>
						<input class="val" placeholder="请输入合计" v-model="hj" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">邮费</view>
						<input class="val" placeholder="请输入邮费" v-model="param.youfei" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">病历本</view>
						<input class="val" placeholder="请输入病历本" v-model="param.bingliben" type="digit"/>
					</view>
					<view class="row">
						<view class="tips">助听器维修费</view>
						<input class="val" placeholder="请输入助听器维修费" v-model="param.zhutingqi" type="digit"/>
					</view>
					<view class="cu-bar bg-white">
						<view class="action text-green" style="margin-left: 580rpx;" @tap="computer()">计算</view>
					</view>
				</view>
			</view>
			<view class="cu-list menu card-menu margin-bottom-xl shadow-lg radius " style="background-color: #fff;">
				<view class="u-header"><text class="tips">计算过程:</text><text class="val">{{data.testCode}}</text></view>
				<view class="u-body">
					<view class="row">
						<view class="tips">检查费</view>
						<input class="val" placeholder="检查费" v-model="jcfgs" disabled/>
					</view>
					<view class="row">
						<view class="tips">治疗费</view>
						<input class="val" placeholder="治疗费" v-model="zlfgs" disabled/>
					</view>		
					<view class="row">
						<view class="tips">药费</view>
						<input class="val" placeholder="药费" v-model="yfhjgs" disabled/>
					</view>		
					<view class="row">
						<view class="tips">合计</view>
						<input class="val" placeholder="合计" v-model="hj" disabled/>
					</view>
					<view class="row">
						<view class="tips">全天收入</view>
						<input class="val" placeholder="全天收入" v-model="qtsrgs" disabled/>
					</view>
				</view>
			</view>
			<view class="cu-list menu card-menu margin-bottom-xl shadow-lg radius " style="background-color: #fff;">
				<view class="u-header"><text class="tips">结果文本:</text><text class="val">{{data.testCode}}</text></view>
				<view class="u-body">
					<textarea placeholder="结果文本" v-model="jgwb"></textarea>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				modalName: null,
				data: {},
				checkbox: [],
				param: {
					gzl: 0,
					cz: 0,
					fz: 0,
					ghzcf: 0,
					cwf: 0,
					gnkjc: 0,
					hyf: 0,
					jcf: 0,
					qt: 0,
					ssf: 0,
					xyf: 0,
					jyf: 0,
					zlf: 0,
					zcaoy: 0,
					jkll: 0,
					jkjj: 0,
					xdjj: 0,
					ylyp: 0,
					cy: 0,
					clf: 0,
					tyf: 0,
					zcy: 0,
					zdhz: 0,
					yz: 0,
					youfei: 0,
					bingliben:0,
					zhutingqi:0
				},
				jcfgs: '功能科检查+化验费',
				zlfgs: '治疗费+透药费',
				yfhjgs: '合计-检查费-治疗费',
				qtsrgs: '合计+邮费+挂号费+病历本+助听器维修费+床位费',
				hj: 0,
				jcfhj: '',
				zlfhj: '',
				yfhj: '',
				qtsr: '',
				jgwb: '1 门诊挂号：工作量[gzl]，初诊[cz]人，复诊[fz]人，挂号诊查费[ghzcf]元。\n2 门诊收费：医院全天收入[hj]元，检查费[jcf]元，药费[yf]元，治疗费[zlf]元。'
			}
		},
		components: {},	
		onShow() {
		},
		methods: {
			computer(){
				this.param.yz = this.getNum(this.param.yz);
				this.param.zdhz = this.getNum(this.param.zdhz);
				this.param.gnkjc = this.getNum(this.param.gnkjc);
				this.param.hyf = this.getNum(this.param.hyf);
				this.param.zlf = this.getNum(this.param.zlf);
				this.param.tyf = this.getNum(this.param.tyf);
				this.param.yz = this.getNum(this.param.yz);
				this.param.zdhz = this.getNum(this.param.zdhz);
				this.param.youfei = parseFloat(this.getNum(this.param.youfei)).toFixed(2);
				this.param.bingliben = parseFloat(this.getNum(this.param.bingliben)).toFixed(2);
				this.param.zhutingqi = parseFloat(this.getNum(this.param.zhutingqi)).toFixed(2);
				this.param.cwf = parseFloat(this.getNum(this.param.cwf)).toFixed(2);

				this.jcfhj = (parseFloat(this.param.gnkjc) + parseFloat(this.param.hyf)).toFixed(2);
				this.zlfhj = (parseFloat(this.param.zlf) + parseFloat(this.param.tyf)).toFixed(2);
				this.jcfgs = "" + this.param.gnkjc + "+" + this.param.hyf + "=" + this.jcfhj;
				this.zlfgs = "" + this.param.zlf + "+" + this.param.tyf + "=" + this.zlfhj;
				this.hj = this.getNum(this.hj);
				this.param.ghzcf = parseFloat(this.getNum(this.param.ghzcf)).toFixed(2);
				this.yfhj = (parseFloat(this.hj) - parseFloat(this.jcfhj) - parseFloat(this.zlfhj) - parseFloat(this.param.cwf)).toFixed(2);
				this.yfhjgs = "" + this.hj + "-" + this.jcfhj + " \n-" + this.zlfhj + " \n-" + this.param.cwf + " \n= " + this.yfhj;
				this.qtsr = (parseFloat(this.hj) + parseFloat(this.param.youfei) + parseFloat(this.param.ghzcf)
					+ parseFloat(this.param.bingliben) + parseFloat(this.param.zhutingqi)).toFixed(2);
				this.qtsrgs = "" + this.hj + "+" + this.param.youfei + "+" + this.param.ghzcf + "+" + this.param.bingliben +"+" + this.param.zhutingqi + "=" + this.qtsr;
				this.param.gzl = this.getNum(this.param.gzl); 
				this.param.cz = this.getNum(this.param.cz);
				this.param.fz = parseInt(this.param.gzl) - parseInt(this.param.cz);
				
				this.jgwb = '1 门诊挂号：工作量[gzl]，初诊[cz]人，复诊[fz]人';
				if(this.param.yz > 0 && this.param.zdhz > 0){
					this.jgwb = this.jgwb + '，其中';
					this.jgwb = this.jgwb + '指定患者[zdhz]人，';
					this.jgwb = this.jgwb + '义诊[yz]人';
				}
				if(this.param.yz <= 0 && this.param.zdhz > 0){
					this.jgwb = this.jgwb + '，其中';
					this.jgwb = this.jgwb + '指定患者[zdhz]人';
				}
				if(this.param.yz > 0 && this.param.zdhz <= 0){
					this.jgwb = this.jgwb + '，其中';
					this.jgwb = this.jgwb + '义诊[yz]人';
				}
				this.jgwb = this.jgwb + '。 \n2 门诊收费：医院全天收入[qtsr]元，其中挂号费[ghzcf]元，检查费[jcf]元，药费[yf]元，治疗费[zlf]元';
				this.jgwb = this.jgwb.replace("[gzl]", this.param.gzl).replace("[cz]", this.param.cz)
							.replace("[fz]", this.param.fz).replace("[ghzcf]", this.param.ghzcf)
							.replace("[ghzcf]", this.param.ghzcf)
							.replace("[qtsr]", this.qtsr).replace("[jcf]", this.jcfhj)
							.replace("[yf]", this.yfhj).replace("[zlf]", this.zlfhj)
							.replace("[zdhz]", this.param.zdhz).replace("[yz]", this.param.yz);
				if(this.param.youfei > 0){
					this.jgwb = this.jgwb + '，邮费' + this.param.youfei + '元'
				}
				if(this.param.bingliben > 0){
					this.jgwb = this.jgwb + '，病历本' + this.param.bingliben + '元'
				}
				if(this.param.zhutingqi > 0){
					this.jgwb = this.jgwb + '，助听器维修费' + this.param.zhutingqi + '元'
				}
				if(this.param.cwf > 0){
					this.jgwb = this.jgwb + '，床位费' + this.param.cwf + '元'
				}
				this.jgwb = this.jgwb + '。'
			},
			getNum(val){
				if(val === 0 || val === '0'){
					return 0;
				}else{
					return val.toString().replace(/^0+/,"");
				}
			}
		},
	}
</script>

<style lang="scss">
	.inputbox {
		margin: 0 auto;
		width: 700rpx;
		height: 80rpx;
		border: 1px #D0D0D0 solid;
		border-radius: 10rpx;
		font-size: 30rpx;
		color: #116AB7;
		line-height: 80rpx;
		padding-left: 20.41rpx;
		display: flex;
		margin-top: 10rpx;
	}
	
	.f_input {
		text-align: left;
		width: 500rpx;
		height: 50rpx;
		margin-left: 20.83rpx;
		margin-top: 15rpx;
	}
	
	.selectbox {
		margin: 0 auto;
		width: 700rpx;
		height: 80rpx;
		border-radius: 10rpx;
		font-size: 30rpx;
		color: #116AB7;
		line-height: 80rpx;
		display: flex;
		margin-top: 10rpx;
		justify-content: space-between;
	}
</style>
